import os
import sys
import base64

from selenium import webdriver

platform = 'win' if sys.platform == 'win32' else 'linux'

current = os.path.abspath(os.path.dirname(__file__))

options = webdriver.FirefoxOptions()

options.add_argument('--headless')
options.add_argument("--start-maximized")

# options.add_argument('--disable-gpu')

browser = webdriver.Firefox(options=options)
browser.get(
    'file://{}'.format(os.path.join(current, '..', 'index.html'))
)

data = browser.print_page()
buffer = base64.b64decode(data)

version = sys.version_info
file = os.path.join(
    current, 'python{}{}{}_{}.pdf'.format(
        version.major,
        version.minor,
        version.micro,
        platform

    )
)
with open(file, 'wb') as fd:
    fd.write(buffer)

browser.quit()
